package cn.edu.ctbu.tydemo1.core;

import cn.edu.ctbu.tydemo1.exception.REnum;
import cn.edu.ctbu.tydemo1.vo.R;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageUtils implements Serializable {

    private static final long serialVersionUID = 1L;
    private int total;
    private List<?> rows;

    public PageUtils(List<?> list,Long total){
        this.rows=list;
        this.total=total.intValue();
    }

    public  PageUtils(List<?> list,int total){
        this.rows=list;
        this.total=total;
    }
    public static R success(Object object){
        R result= new R();
        result.setCode(1);
        result.setData(object);
        result.setMsg("成功执行");

        return result;
    }
    public static R success(){
        return success(null);

    }
    public static R error(Integer code,String msg){
        R result= new R();
        result.setCode(code);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }
    public static R error(REnum rEnum){
        return error(rEnum.getCode(),rEnum.getMsg());
    }
}
